package com.gpzx.zx.module.home.ui.adapter

import android.content.Context
import android.util.Log
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.gpzx.zx.databinding.ItemNews24Binding
import com.gpzx.zx.databinding.ItemOrgListBinding
import com.gpzx.zx.module.home.frame.model.QKLNewsInfo
import com.wkq.lib_base.adapter.KtDataBindingAdapter
import com.wkq.lib_base.adapter.KtDataBindingViewHolder

/**
 * 作者: 吴奎庆
 *
 * 时间: 2020/7/16
 *
 * 简介:
 */
class News24Adapter(context: Context, layoputId: Int) : KtDataBindingAdapter<QKLNewsInfo>(context, layoputId) {

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        var bindingHolder = holder as KtDataBindingViewHolder
        var binding = bindingHolder.viewBinding as ItemNews24Binding
        binding.data = getItem(position)
        if (position == 0) {
            binding.vLineTop.visibility = View.INVISIBLE
        } else {
            binding.vLineTop.visibility = View.VISIBLE
        }
        if (position == itemCount - 1) binding.vLineBottom.visibility = View.GONE
        Log.e("总条数:", itemCount.toString())
        Log.e("position:", position.toString())
        if (viewClickListener != null) {
            binding.root.setOnClickListener {
                viewClickListener?.onViewClick(binding.root, getItem(position))
            }
        }
    }
}